home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
aminet
/
mus
/
edit
/
amisox_wav.lha
/
ami.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-08
|
1KB
|
48 lines
/* needed functions for Amiga sox *
* D. Champion, 26 Apr 1992 *
* other necessities, such as *
* bcopy() and index() #defines, *
* may be found in "st.h" */
#include <exec/types.h>
#include <exec/tasks.h>
#include <stdio.h>
#ifndef P_tmpdir
#define P_tmpdir "t:"
#define B_tmpnam 5
#undef L_tmpnam
#define L_tmpnam sizeof(P_tmpdir)+B_tmpnam+21
/* sizeof(P_tmpdir) includes terminating null; B_tmpnam is how much *
* of myname to include; 8x2 for hex longs + 3 dots + 2 sequence nums */
#endif
char tmpnam_count=0;
char *tmpnam(char *s)
{
extern char *myname; /* myname MUST exist! */
extern char tmpnam_count;
char *uniqsuff=".00000000.00000000.00";
int i;
strcpy (s,P_tmpdir);
strncat(s,myname,B_tmpnam); /* start tmpfilename with 1st B_tmpnam chars of myname */
sprintf(uniqsuff,".%8x.%8x.%2x\0",(ULONG)FindTask(NULL),(ULONG)time(),(char)tmpnam_count);
for(i=0;i<L_tmpnam+B_tmpnam;i++) {
if (uniqsuff[i]==' ') uniqsuff[i]='0';
}
strcat (s,uniqsuff);
tmpnam_count++;
return(s);
}
FILE *tmpfile(void)
{
FILE *file;
char fnam[L_tmpnam];
return(file=fopen(tmpnam(fnam),"wb+"));
}